package castledefense.game.screens;

import castledefense.data.GameData;
import castledefense.game.render.Cam;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public abstract class AbstractScreen implements Screen, InputProcessor {
	protected final SpriteBatch spriteBatch;
	
	public AbstractScreen(SpriteBatch spriteBatch) {
		this.spriteBatch = spriteBatch;		
	}
	
	private float evenDeltaError = 0;
	public final void render(float delta) {
		evenDeltaError += 1000f* delta;
		final int evenDelta = (int)evenDeltaError;
		evenDeltaError -= evenDelta;
		update(evenDelta);
		draw();
	}
	
	public final SpriteBatch getSpriteBatch(){
		return spriteBatch;
	}

	public abstract void update(int deltaTime);

	public abstract void draw();

	public void dispose() {

	}

	public void hide() {
	}

	public void pause() {
	}

	public void resize(int width, int height) {
		Cam.camera.viewportWidth = width;
		Cam.camera.viewportHeight = height;
		GameData.resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
	}

	public void resume() {
	}

	public void show() {
	}

	public boolean keyDown(int keyCode) {
		return false;
	}

	public boolean keyTyped(char character) {
		return false;
	}

	public boolean keyUp(int keyCode) {
		return false;
	}

	public boolean scrolled(int amount) {
		return false;
	}

	public boolean touchDown(int x, int y, int pointer, int button) {
		return false;
	}

	public boolean touchDragged(int x, int y, int pointer) {
		return false;
	}

	public boolean touchMoved(int x, int y) {
		return false;
	}

	public boolean touchUp(int x, int y, int pointer, int button) {
		return false;
	}
}
